package com.example.mybaseapp.ui

import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.mybaseapp.R
import com.example.mybaseapp.widget.my_circle_seekbar.MyCircleSeekBar
import com.example.mybaseapp.widget.my_circle_seekbar.SelectListener
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch

class HalfCircleActivity : AppCompatActivity() {
    private val points = mutableListOf(-6F,-3F,0F,3F,6F,9F,12F,15F,16F)
    private val points2 = (-6..16).toList()
    private val points3 = (-6..-6).toList()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_half_circle)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        initView()
    }

    private fun initView() {
//        findViewById<MyCircleSeekBar>(R.id.my_circle_seek_bar).addPoints(points)
        findViewById<MyCircleSeekBar>(R.id.my_circle_seek_bar).apply {
            addPoints(points2)
            circleUtil.mSelectListener = object :SelectListener{
                override fun selectPoint(value: Any) {
                    MainScope().launch(Main){
                        Toast.makeText(this@HalfCircleActivity, "当前选中的是$value", Toast.LENGTH_SHORT).show()
                    }
                }
            }
        }
    }
}